/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-13 13:37:44
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-10-19 09:38:20
 * @FilePath: \adminstration\src\Common\Router\MenuNavList\Camera\CameraTimeLapse.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, AnnexButton } from '../Common/options'
import { CameraList } from '../Common/Conversion'

export const CameraTimeLapse = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const cameraUuid = await CameraList()
    let data = {
        type: '监控管理',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission?.findIndex(v => v.uuid === '6ab91752-7570-43a4-af4f-f5bd32188a8a') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'projectUuid',
                title: '项目名称',
                rules: true,
                valueType: 'select',
                valueEnum: ClientData.project,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            {
                ...commonTableList.organizationUuid,
                valueEnum: ClientData.organization,
                hideInAdded: true,
                hideInModify: true,
                width: 200,
            },
            {
                dataIndex: 'cameraUuid',
                title: '摄像头名称',
                rules: true,
                width: 150,
                valueType: 'select',
                valueEnum: cameraUuid,
            },
            {
                dataIndex: 'tableName',
                title: '视频名称',
                valueType: 'input',
                rules: true,
                width: 220,
            },
            { ...commonTableList.sortId, rules: true },
            {
                dataIndex: 'dayCount',
                title: '每天图片数量',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'imageUrl',
                title: '保存图的地址',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 220,
            },
            {
                dataIndex: 'videoUrl',
                title: '视频地址',
                valueType: 'input',
                hideInSearch: true,
                width: 220,
            },
            {
                dataIndex: 'otherItemVideoUrl',
                title: '第三方项目视频地址',
                valueType: 'input',
                hideInSearch: true,
                ellipsis: true,
                width: 300,
            },

            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { videoPath } = record
                    return [
                        Permission.findIndex(v => v.uuid === 'ec24679e-bd0c-449a-86aa-bc2ea904a41d') !== -1 && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        videoPath && (
                            <AnnexButton OptionsEvent={OptionsEvent} key="see" url={videoPath} title="视频画面" />
                        ),
                        // <TwoModalBtn
                        //     key="TwoModal"
                        //     towKey="CameraTimeLapseDetail"
                        //     OptionsEvent={OptionsEvent}
                        //     pageHeaderData={data.columns}
                        //     data={record}
                        //     title="附件信息"
                        // />,
                        Permission.findIndex(v => v.uuid === 'dc85a200-b097-4be9-82e4-c99dca6ba62c') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
